home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c / 303 < prev    next >
Internet Message Format  |  1996-08-06  |  4KB

  1. Path: tko.dec.com!diamond
  2. From: diamond@tko.dec.com (Norman Diamond)
  3. Newsgroups: comp.lang.c,comp.os.ms-windows.nt.misc,comp.programming,comp.std.c,comp.unix.aix
  4. Subject: Re: function pointers
  5. Date: 5 Feb 1996 03:46:51 GMT
  6. Organization: Digital Equipment Corporation Japan , Tokyo
  7. Message-ID: <4f3ujb$9s8@usenet.pa.dec.com>
  8. References: <4eogio$gt0@giga.bga.com> <4eohgr$gt0@giga.bga.com> <sXEExQ9ytBGL084yn@csn.net> <4es7vo$bih@usenet.pa.dec.com> <4f090o$2hn4@ausnews.austin.ibm.com>
  9. Reply-To: diamond@jrdv04.enet.dec-j.co.jp (Norman Diamond)
  10. NNTP-Posting-Host: jit533.tko.dec.com
  11.  
  12. In article <4f090o$2hn4@ausnews.austin.ibm.com>, hook@austin.ibm.com (Gary R. Hook) writes:
  13. >In article <4es7vo$bih@usenet.pa.dec.com>, diamond@tko.dec.com (Norman Diamond) writes:
  14. >> After seeing several followups which were either wrong or else technically
  15. >> correct but non-responsive to the original poster's problem, and seeing
  16. >> which newsgroups they were posted to, I wish to point out that only one
  17. >> followup correctly answered the original poster's problem.
  18. >> Thad Smith's posting with message-id <sXEExQ9ytBGL084yn@csn.net>
  19. >> had the correct answer (and another partial answer with correct warning).
  20. >> If you try relying on any of the others, you will get bitten someday, or
  21. >> if not you then innocent bystanders will get bitten by your work.
  22.  
  23. >Begging your pardon, but pretty much every one who responded to the post
  24. >had a "correct" answer; the original question was how to get the code
  25. >to compile on AIX.
  26.  
  27. There are a million ways to get a slightly changed code to compile on AIX,
  28. some of which will cause core dumps at execution time, some of which will
  29. execute to completion while printing wrong answers, some of which will be
  30. luckier, and some of which will be unluckier.  I did not see which part of
  31. the original posting asked to avoid a slightly changed code that would obey
  32. the standard, with possibility of compiling and executing correctly on all
  33. conforming implementations.
  34.  
  35. >The original code was incorrect, in that the casting
  36. >that was being done did not really address the complaint from the
  37. >compiler.  The "solution" is to properly perform the casts to the
  38. >associated types, i.e. function pointers taking and returning the
  39. >required data types, as opposed to casting to struct pointers, which
  40. >doesn't affect the function pointer in the least.
  41.  
  42. Indeed, the solution is to PROPERLY perform the casts to the associated
  43. types.  Thad Smith's posting did this.
  44.  
  45. Your posting did not do this.  You cast the function pointer type instead.
  46. Your posting didn't include code to cast the arguments and parameters.
  47. I'll take your word for it that under AIX, if a caller passes a void*
  48. argument to a function which expected a double*, and the void* argument
  49. does not get converted to the double* type of the parameter, the invoked
  50. function will still work.  Today anyway.  I think your employer was aware
  51. that this kind of game was not reliable, when it developed the syntax for
  52. declaring ENTRYs in PL/I.  C was invented around 7 years after PL/I and
  53. this game did not become any more reliable during that time or since.
  54.  
  55. >The fact that what the original coder was trying to accomplish is
  56. >quite non-portable, and can wreak havoc for others, was an appropriate
  57. >comment by Thad, but the addition of his warning didn't make his
  58. >answer any more correct than any of the others, did it?  Or perhaps
  59. >we saw different responses to the posed question...
  60.  
  61. Thad Smith posted both a correct answer *and* an addition of a warning
  62. to the same kind of game that you posted without warning.  Either one
  63. of these would have been enough to make his answer more correct.
  64. It sure does look like we saw different responses.  Look again.
  65.  
  66. >Good for XL C for refusing to compile this sort of code without complaint.
  67.  
  68. I agree.  Maybe you can learn from your colleagues.
  69. --
  70.  <<  If this were the company's opinion, I would not be allowed to post it.  >>
  71. "I paid money for this car, I pay taxes for vehicle registration and a driver's
  72. license, so I can drive in any lane I want, and no innocent victim gets to call
  73. the cops just 'cause the lane's not goin' the same direction as me" - J Spammer
  74.